#include "sylar/address.h"
#include "sylar/head.h"
#include <map>

sylar::Logger::ptr g_logger = SYLAR_LOG_ROOT();

void test(){
	std::vector<sylar::Address::ptr> addrs;
	bool v = sylar::Address::Lookup(addrs, "swpuacm.cn:80");
	if(!v){
		SYLAR_LOG_ERROR(g_logger) << "lookup fail";
		return ;
	}
	for(size_t i = 0;i < addrs.size();++i){
		SYLAR_LOG_INFO(g_logger) << i << " - " << addrs[i]->toString();
	}
}

void test_iface(){
	std::multimap<std::string, std::pair<sylar::Address::ptr, uint32_t> >results;

	bool v = sylar::Address::GetInterfaceAddress(results);
	if(!v){
		SYLAR_LOG_ERROR(g_logger) << "GetInterfaceAddress failed";
		return ;
	}
	for(auto &i : results){
		SYLAR_LOG_INFO(g_logger) << i.first << " - " << i.second.first->toString() << " - " << i.second.second;
	}
}

void test_ipv4(){
	auto addr = sylar::IPAddress::Create("127.0.0.8");
	SYLAR_LOG_INFO(g_logger) << addr->toString();
}

int main()
{
	test_ipv4();
	return 0;
}